<template>
  <div id="community">
    <el-table border :data="detail.list" style="width: 100%">
      <el-table-column type="index" label="序号" width="100" align="center"/>
      <el-table-column prop="neirong" label="内容" align="center" />
      <el-table-column prop="uid" label="用户id" align="center"/>
      <el-table-column fixed="right" align="center">
        <template #header>
          编辑
        </template>
        <template #default="scope">
          <el-button
            size="large"
            type="danger"
            @click="handleDelete(scope.$index)"
            >删除</el-button>
          
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>

import axios from "axios";
import qs from "querystring";
export default {
  name: "SelectUserVue",
  data() {
    return {
      detail: [
        {
          list: [{}],
        },
      ],
      current: {},
      dialogFormVisible: false,
    };
  },
  methods: {
    handleDelete(index) {
      axios
        .post(
          "http://localhost:8080/library/shanchujianYi",
          qs.stringify(this.detail.list[index]),
          {
            headers: {
              "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
            },
          }
        )
        .then((res) => {
          console.log(res.data.code);
          if (res.data.code == 1) {
            window.alert("删除成功！");
          } else {
            console.log("error");
          }
        });
    },
    mount() {
      axios
        .post(
          "http://localhost:8080/library/chakanjiajianYi",
          qs.stringify(this.list),
          {
            headers: {
              "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
            },
          }
        )
        .then((res) => {
          console.log(res.data);
          if (res.data.code == 1) {
            this.detail.list = res.data.data;
          } else {
            console.log("error");
          }
        });
    },
  },
  mounted() {
    this.mount();
  },
};
</script>

<style scoped>
</style>